home *** CD-ROM | disk | FTP | other *** search
- #include "struct.c"
- #include "WinPlot.h"
-
- struct MsgPort *RexxReplyPort = NULL;
- static struct RexxMsg *OutRexxMsg = NULL;
- static UBYTE *CmdArgstring = NULL;
-
- /* Init the ARexx Port */
- void _STI_250_OpenRexx(void)
- {
- RexxReplyPort = CreateMsgPort();
- OutRexxMsg = CreateRexxMsg(RexxReplyPort,NULL,"REXXPLOT");
- }
-
- /* Close the ARexx Port */
- void _STD_250_CloseRexx(void)
- {
- if (RexxReplyPort) DeleteMsgPort(RexxReplyPort);
- if (OutRexxMsg) DeleteRexxMsg(OutRexxMsg);
- }
-
- /* the Rexx command list */
- static struct List RexxList =
- {
- (struct Node *)&RexxList.lh_Tail, NULL, (struct Node *)&RexxList.lh_Head
- };
-
- static void SendFirst(void)
- {
- struct MsgPort *TargetPort;
- char *Command = RexxList.lh_Head->ln_Name;
-
- if (CmdArgstring=CreateArgstring(Command,strlen(Command)))
- {
- OutRexxMsg->rm_Action=RXCOMM|RXFF_NOIO|RXFF_STRING;
- OutRexxMsg->rm_Args[0]=(STRPTR)CmdArgstring;
-
- Forbid();
- if (TargetPort=FindPort(RXSDIR))
- PutMsg(TargetPort,&OutRexxMsg->rm_Node);
- Permit();
- }
- }
-
- void SendRexxMsg(char *Command)
- {
- struct Node *RexxNode;
- UBYTE *QuotedCommand;
- BOOL Send;
-
- Send = RexxList.lh_Head->ln_Succ == NULL;
-
- QuotedCommand = malloc(strlen(Command)+3);
- sprintf(QuotedCommand, "'%s'", Command);
- RexxNode = malloc(sizeof(struct Node));
- RexxNode->ln_Name = QuotedCommand;
- AddTail(&RexxList, RexxNode);
-
- if (Send && RexxReplyPort && OutRexxMsg)
- SendFirst();
- }
-
- void ReplyRexxMsg(void)
- {
- struct Node *First;
-
- DeleteArgstring(CmdArgstring);
-
- First = RexxList.lh_Head;
- RemHead(&RexxList);
-
- free(First->ln_Name);
- free(First);
- if (RexxList.lh_Head->ln_Succ != NULL)
- SendFirst();
- }
-
- void LoadFunc(void)
- {
- struct Window *wnd;
- char Buffer[255], Buffer2[255];
-
- set(AP_WinPlot, MUIA_Application_Sleep, TRUE);
- get(WI_WinPlot, MUIA_Window_Window, &wnd);
- if (MUI_AslRequestTags(FileReq,
- ASLFR_DoSaveMode, FALSE,
- ASLFR_Window, wnd,
- ASLFR_TitleText, "Please select new file to plot",
- ASLFR_DrawersOnly, FALSE,
- TAG_END))
- {
- strcpy(Buffer2, FileReq->fr_Drawer);
- AddPart(Buffer2, FileReq->fr_File, 255);
- sprintf(Buffer, "load \"%s\"", Buffer2);
- SendRexxMsg(Buffer);
- }
- set(AP_WinPlot, MUIA_Application_Sleep, FALSE);
- }
-
- void SaveFunc(void)
- {
- struct Window *wnd;
- char Buffer[255], Buffer2[255];
-
- set(AP_WinPlot, MUIA_Application_Sleep, TRUE);
- get(WI_WinPlot, MUIA_Window_Window, &wnd);
- if (MUI_AslRequestTags(FileReq,
- ASLFR_DoSaveMode, TRUE,
- ASLFR_Window, wnd,
- ASLFR_TitleText, "Please select file to save gnuplot state",
- ASLFR_DrawersOnly, FALSE,
- TAG_END))
- {
- strcpy(Buffer2, FileReq->fr_Drawer);
- AddPart(Buffer2, FileReq->fr_File, 255);
- sprintf(Buffer, "save \"%s\"", Buffer2);
- SendRexxMsg(Buffer);
- }
- set(AP_WinPlot, MUIA_Application_Sleep, FALSE);
- }
-
- void CDFunc(void)
- {
- struct Window *wnd;
- char Buffer[255];
-
- set(AP_WinPlot, MUIA_Application_Sleep, TRUE);
- get(WI_WinPlot, MUIA_Window_Window, &wnd);
- if (MUI_AslRequestTags(FileReq,
- ASLFR_DoSaveMode, FALSE,
- ASLFR_Window, wnd,
- ASLFR_TitleText, "Please select new current directory",
- ASLFR_DrawersOnly, TRUE,
- TAG_END))
- {
- sprintf(Buffer, "cd \"%s\"", FileReq->fr_Drawer);
- SendRexxMsg(Buffer);
- }
- set(AP_WinPlot, MUIA_Application_Sleep, FALSE);
- }
-